#*******************************************************************
#* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        *
#*                                                                 *
#*  NOTE      = 共通makefile信息
#*  DATE      = 
#*******************************************************************
#打包编译后目录
COMM_DIST               ?= ../../../dist
COMM_DIST_DIR_DEV       =$(COMM_DIST)/dev
COMM_DIST_DIR_DEV_SO    =$(COMM_DIST_DIR_DEV)/lib
COMM_DIST_DIR_DEV_INC   =$(COMM_DIST_DIR_DEV)/include

COMM_DIST_DIR_BIN       =$(COMM_DIST)/bin
COMM_DIST_DIR_SO        =$(COMM_DIST)/lib
COMM_DIST_DIR_LUALIB    =$(COMM_DIST)/lualib/lib
COMM_TEMPLATE_DIR_CONF  =$(COMM_DIST)/../conf/modules
COMM_DIST_DIR_CONF      =$(COMM_DIST)/conf/modules

COMM_FRAMEWORK_VER      =5.1

#正式发布时使用1
COMM_RELEASE = 0
#COMM_RELEASE = 1

APMMODULE               =$(COMM_DIST_DIR_DEV_INC)/apmmodule

#xml2
XML2LIB = `xml2-config --libs`
#XML2LIB  = /usr/local/lib/libxml2.a -lz -lm -ldl

#jemalloc配置
#调试解析模块时，不加载jemalloc=0
#需要使用时，设定为1
enable_frcomm_use_jemalloc = 0
#enable_frcomm_use_jemalloc = 1

CFLAGS_EXT  = -g -Wall
#CFLAGS_EXT  = -pg -Wall

ifeq ($(COMM_RELEASE), 0)
	# 发现异常后主动cordump
	# CFLAGS_EXT  += -DFRDBG_COREDUMP

	# 单笔申请内存超过一定内存时,主动coredump
	# CFLAGS_EXT  += -DFRDBG_OVER_LIMIT_MEM_COREDUMP
endif

LIBS_EXT    =

TARGET_LIB_APMCOMM  =apm_comm_1.0.a
TARGET_LIB_APMCOMM_C=apm_comm_c_1.0.a
TARGET_LIB_APMMODULE=apm_module_1.0.a
TARGET_LIB_APMSHM   =apm_shm_3.0.a

LIB_A_APM_COMM     =$(COMM_DIST_DIR_DEV_SO)/$(TARGET_LIB_APMCOMM)
LIB_A_APM_COMM_C   =$(COMM_DIST_DIR_DEV_SO)/$(TARGET_LIB_APMCOMM_C)
LIB_A_APM_SHM      =$(COMM_DIST_DIR_DEV_SO)/$(TARGET_LIB_APMSHM)
LIB_I_APM_COMM     =$(COMM_DIST_DIR_DEV_INC)/apmcomm
LIB_I_APM_SHM      =$(COMM_DIST_DIR_DEV_INC)/apmshm
LIB_A_APM_MODULE   =$(COMM_DIST_DIR_DEV_SO)/$(TARGET_LIB_APMMODULE)
LIB_I_APM_MODULE   =$(COMM_DIST_DIR_DEV_INC)/apmmodule
LIB_I_APM_PLUGINLUA=$(COMM_DIST_DIR_DEV_INC)/pluginLua

#对应redhat
#需要使用时，设定为redhat4使用4,redhat5使用5
enable_dbg_rdel = 0
#enable_dbg_rdel = 4
#enable_dbg_rdel = 5

#对应centos7编译
enable_centos7=0
#enable_centos7=1

#luajit控制
enable_luajit=1
#enable_luajit=0

ifeq ($(enable_dbg_rdel), 0)
    CC          := gcc
    CX          := g++
    CFLAGS_EXT += -D_BSD_SOURCE
else
    CC          := insure
    CX          := insure g++
    COMM_RELEASE = 0
    enable_luajit=0

    ifeq ($(enable_dbg_rdel), 5)
        CFLAGS_EXT += -D_BSD_SOURCE -DFRLINUX5
    else
        CFLAGS_EXT += -D_GNU_SOURCE -D__USE_BSD -DFRLINUX4
    endif
endif

ifeq ($(enable_luajit), 1)
    LIB_LUA     = -lluajit-5.1
    CFLAGS_EXT += -DLIB_APM_LUAJIT
else
    LIB_LUA= -llua
endif

#jemalloc配置
ifeq ($(COMM_RELEASE), 1)
    enable_frcomm_use_jemalloc = 1
endif

ifeq ($(enable_frcomm_use_jemalloc), 1)
    LIBS_EXT    += -ljemalloc
endif

ifeq ($(enable_centos7), 1)
    LIBS_EXT    += -lpthread
	CFLAGS_EXT  += -DFRAPM_CENTOS7
endif

# EOF
